//******************************************************************************
//
//                 Low Cost Vision
//
//******************************************************************************
// Project:        cratedemo
// File:           Crate.hpp
// Description:    Base class for crates.
// Author:         Wouter Langerak & Lukas Vermond
// Notes:
//
// License:        GNU GPL v3
//
// This file is part of cratedemo.
//
// cratedemo is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// cratedemo is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with cratedemo.  If not, see <http://www.gnu.org/licenses/>.
//******************************************************************************
#pragma once

#include <cstdlib>
#include <string>

#include <equipletnode/CrateContent.hpp>
#include <datatypes/point2.hpp>
#include <datatypes/point3.hpp>
#include <datatypes/size3.hpp>

/**
 * Base class for crates.
 */
class Crate {

public:
	Crate(
		std::string name,
		datatypes::point2f position,
		float angle,
		bool moving,
		std::vector<CrateContent*>& crateContent);
		
	virtual ~Crate();
	/**
	 * Puts a CrateContent* in the list of containing items on location index.
	 * @param index Location of the to be inputed CrateContent*.
	 * @param crateContent Pointer of the to be inputed CrateContent.
	 */
	void put(size_t index, CrateContent* crateContent);
	/**
	 *
	 */
	CrateContent* get(size_t index) const;
	/**
	 * Returns the location of the object on index.
	 * @param index
	 * @return the location of the object on index.
	 */
	void remove(size_t index);
	/**
	 * Returns if the Crate is empty.
	 * @return
	 */
	bool isEmpty() const;
	bool isIndexEmpty(size_t index) const;
	
	const std::string& getName(void) const;

public:
	datatypes::point2f position;
	float angle;
	bool moving;
	std::vector<CrateContent*>& data;
	
	datatypes::point3f getContainerLocation(size_t index) const;
	datatypes::point3f getContentGripLocation(size_t index) const;
	
	bool isScanned;
	
	double crate_width;
	double crate_height;
	double crate_depth;
	int grid_width;
	int grid_height;
	double distance_to_side;
	double distance_to_next;
	double radius_of_ball_container;
	double bottom_thickness;
	
	datatypes::size3f size;
	
	static char* crate_info;
private:
	void get_xml_data(char* path);
	
	std::string name;
};

